package com.liuda066.forumssm.controller;

import com.liuda066.forumssm.exception.ApplicationException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : niu niu
 * @version : 1.0.0
 * @date : 2023/8/31 20:21
 */
@Api(tags = "测试接口")
@RestController
@RequestMapping("/test")
public class TestController {

    @ApiOperation("测试打印")
    @GetMapping("/hello")
    public String hello(){
        return "hello....";
    }

    @ApiOperation("测试传参")
    @GetMapping("/helloByName")
    public String testHelloByName(@ApiParam("名字") String name){
        return "hello ,"+name;
    }

    @ApiOperation("测试异常")
    @GetMapping("/exception")
    public String testException() throws Exception {
        throw  new Exception("这是一个Exception");
    }

    @ApiOperation("测试自定义异常")
    @GetMapping("/applicationException")
    public String testAppException() throws ApplicationException {
        throw  new ApplicationException("这是一个applicationException");
    }
}
